package com.sgs.soda.core;

import java.io.Serializable;

/**
 * @author Tim_Tian
 * @date 2021/7/22 14:15
 */
public class GeneralResult<T> implements Serializable {
    private int status = 200;
    private String message;
    private T data;

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }


    public GeneralResult<T> success() {
        this.status = RespEnum.SUCCESS.getValue();
        this.message = RespEnum.SUCCESS.getMsg();
        return this;
    }

    public GeneralResult<T> fail(){
        return this.fail(RespEnum.FAIL.getMsg());
    }

    public GeneralResult<T> fail(String message){
        this.status = RespEnum.FAIL.getValue();
        this.message = message;
        return this;
    }

    public static <T> GeneralResult<T> newInstance(){
        return new GeneralResult<T>();
    }

}
